package com.problemproject.dome.viewpager;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;

import com.problemproject.dome.R;

import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;

public class TabFragment extends Fragment {

    private View view;
    private TextView fragmentTab;
    private ListView listView;
    private List<String> mList = new ArrayList<>();
    public  static TabFragment getInstance(String name){
            TabFragment tabFragment = new TabFragment();
            Bundle arguments = new Bundle();
            arguments.putString("name",name);
            tabFragment.setArguments(arguments);
        return tabFragment;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull  LayoutInflater inflater, @Nullable  ViewGroup container, @Nullable  Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_tab, container, false);
        return view;
    }


    @Override
    public void onActivityCreated(@Nullable  Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        intiView();
        Bundle arguments = getArguments();
        String name = arguments.getString("name","");
        fragmentTab.setText(name);
        for (int i = 0; i < 9; i++) {
            mList.add(name+i);
        }
        TabListViewAdapter tabListViewAdapter = new TabListViewAdapter(getActivity(), mList);
        listView.setAdapter(tabListViewAdapter);
    }

    private void intiView() {
        fragmentTab = (TextView) view.findViewById(R.id.fragment_tab);
        listView = (ListView) view.findViewById(R.id.listView);
    }


}